<?php

/**
 * Portfolio form.
 *
 * @package    lezgro
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class PortfolioForm extends BasePortfolioForm
{
  public function configure()
  { 
      $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'solution_id'=> new sfWidgetFormInputHidden(),
      'title'           => new sfWidgetFormInputText(array(),array('onBlur'=>'return generateUri("portfolio"); ')),
      'slug'            => new sfWidgetFormInputText(),
      'about'           => new sfWidgetFormTextarea(),
      'main_image_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('MainImage'), 'add_empty' => true),array('style'=>'display: none')),
      'title_image_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TitleImage'), 'add_empty' => true),array('style'=>'display: none'))
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'solution_id'              => new sfValidatorInteger(array('required'=>false)),
      'user_profile_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('UserProfile'))),
      'title'           => new sfValidatorString(array('max_length' => 255)),
      'about'           => new sfValidatorString(array('max_length' => 1000)),
      'main_image_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('MainImage'), 'required' => false)),
      'title_image_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TitleImage'), 'required' => false)),
      'slug'            => new sfValidatorString(array('max_length' => 255))
    ));

    $this->widgetSchema->setNameFormat('portfolio[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();
  }
  public function bind(array $taintedValues = null, array $taintedFiles = null) {
       $taintedValues['user_profile_id']=sfContext::getInstance()->getUser()->getUserProfile()->getId();
        return parent::bind($taintedValues, $taintedFiles);
    }
}